package com.zhangbo.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.zhangbo.entity.User;

public interface UserMapper {

	@Insert("INSERT INTO user (`uname`,`password`,`locked`, `createTime`, `updateTime`,`role`) \r\n"
			+ "VALUES(#{uname}, #{password},0,now(),now(),0)")
	int add(User user);

	@Select("SELECT uid,uname,`password`,`locked`,`role` FROM user WHERE uname = #{value}")
	User findByName(String uname);

	@Select("SELECT uid ,uname, `password`, locked, role ,createTime FROM user ORDER BY createTime DESC")
	List<User> list();

	@Update("UPDATE user SET `locked` = #{locked}"
			+ " WHERE `uid` = #{uid}")
	int updateLocked(@Param("uid")int userid,@Param("locked") int status);

}
